//
//  ViewController.swift
//  TuQiangMedia
//
//  Created by XieLB on 2018/9/29.
//  Copyright © 2018年 XieLB. All rights reserved.
//

import UIKit

class ViewController: UIViewController {

    override func viewDidLoad() {
        
        super.viewDidLoad()
        
        //        let btn = UIButton.init(frame: CGRect.init(x: 100, y: 100, width: 200, height: 50))
        //        btn.setTitle("download", for: .normal)
        //        btn.backgroundColor = UIColor.orange
        //        btn.addTarget(self, action: #selector(didDownload), for: .touchUpInside)
        //        view.addSubview(btn)
        let pushLocalRecordBtn = UIButton.init(frame: CGRect.init(x: 100, y: 100, width: 200, height: 50))
        pushLocalRecordBtn.setTitle("present Local Record play", for: .normal)
        pushLocalRecordBtn.backgroundColor = UIColor.orange
        pushLocalRecordBtn.addTarget(self, action: #selector(didPushLocalRecordBtn), for: .touchUpInside)
        view.addSubview(pushLocalRecordBtn)
        
        let pushRecordBtn = UIButton.init(frame: CGRect.init(x: 100, y: 200, width: 200, height: 50))
        pushRecordBtn.setTitle("present Record play", for: .normal)
        pushRecordBtn.backgroundColor = UIColor.orange
        pushRecordBtn.addTarget(self, action: #selector(didPushRecordBtn), for: .touchUpInside)
        view.addSubview(pushRecordBtn)
        
        let pushVedioBtn = UIButton.init(frame: CGRect.init(x: 100, y: 300, width: 200, height: 50))
        pushVedioBtn.setTitle("present vedio play", for: .normal)
        pushVedioBtn.backgroundColor = UIColor.orange
        pushVedioBtn.addTarget(self, action: #selector(didPushVedioBtn), for: .touchUpInside)
        view.addSubview(pushVedioBtn)
        
    }
    
    override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
        
    }
    
    
    @objc func didDownload() {
        //        CTMediator.sharedInstance()?.tq_playVedio(filePath: "")
        
        CTMediator.sharedInstance()?.tq_downloadVedio(downloadUrl: "http://statics.aichezaixian.com/351609080199717_1_2018_08_10_10_31_43", closer: { dic in
            print("\(dic)")
            guard let state = dic["state"] as? String else {
                return
            }
            if state == "loading" {
                
            }else if state == "succeed" {
                
            }
        })
    }
    
    @objc func didPushLocalRecordBtn() {
        let ctrl = LocalVedioViewController()
        self.navigationController?.pushViewController(ctrl, animated: true)
    }
    
    @objc func didPushVedioBtn() {
        let ctrl = VedioViewController()
        self.navigationController?.pushViewController(ctrl, animated: true)
        //        present(ctrl, animated: true, completion: nil)
    }
    
    @objc func didPushRecordBtn() {
        let ctrl = RecordViewController()
        self.navigationController?.pushViewController(ctrl, animated: true)
    }
}

